home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD ROM Paradise Collection 4
/
CD ROM Paradise Collection 4 1995 Nov.iso
/
os2
/
adaptor.zip
/
ADAPT.ZIP
/
adaptor
/
examples
/
simple
/
pi.f
< prev
next >
Wrap
Text File
|
1993-11-30
|
513b
|
21 lines
c numerical integration to calculate pi
program pi
integer i, n
real*8 w, v(:), gsum, pi
print *, 'Input number of points : '
read *, n
call cm_timer_clear (0)
call cm_timer_start (0)
w = 1.0 / n
allocate (v(n))
v = ([1:n] -0.5 )* w
v = 4.0 / (1.0 + v * v)
gsum = sum (v)
call cm_timer_stop (0)
print *, 'pi ist approximated with ', gsum *w
call cm_timer_print (0)
deallocate (v)
end